package Lib3d.SceneGraph.Impl;


import Lib3d.Draw;
import Lib3d.Object3d;
import Lib3d.Loader.ObjLoader;
import Lib3d.MyUtils.MaterialLibSingleton;
import Lib3d.SceneGraph.Geometry;

import java.io.IOException;
import java.util.Vector;

import javax.media.opengl.GLAutoDrawable;

/**
 * A geometry scene graph child implementation.
 * 
 * @author Wassim Chegham
 * @author Miriam Baran-Surel
 * @version 0.1
 * @category Lib3d.SceneGraphImpl
 * 
 */
public class GeometryImpl implements Geometry {

    private Vector<Object3d> object3d;

    public GeometryImpl(final String ObjPath) {
        try {
            this.object3d = new Vector<Object3d>();
            ObjLoader.load(ObjPath, this.object3d);
        }
        catch (final IOException e) {
            e.printStackTrace();
        }
    }

    public void draw(final GLAutoDrawable gLDrawable) {
        for (int cpt = 0; cpt < this.object3d.size(); ++cpt) {
            Draw.draw(gLDrawable, this.object3d.get(cpt),
                    MaterialLibSingleton.getInstance());
        }
    }

    public Vector<Object3d> getObjects() {
        return this.object3d;
    }

}
